/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ejb;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import jpa.Comuni;
import jpa.Province;

@Stateless
public class GestoreProvince implements GestoreProvinceLocal{

    @PersistenceContext
    private EntityManager em;

    @Override
    public List<Province> listaProvince() {
        Query query = em.createNamedQuery("Province.findAll");
        List<Province> result = query.getResultList();
        return result;
    }

    @Override
    public List<Comuni> listaComuni(Integer parametro) {
        Query query = em.createNamedQuery("Comuni.findByIdProvincia");
        query.setParameter("idProvincia", parametro);
        List<Comuni> result = query.getResultList();
        return result;
    }

}